package com.jie.deletefile.xListview.xlistview;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.jie.deletefile.R;

import java.util.List;

/**
 * Created by 13952137957 on 2016/11/8.
 */

public class MyAdapter extends ArrayAdapter {

    private Context context;
    private int resID;
    private List<String> data;
    public MyAdapter(Context context, int resource, List<String> objects) {
        super(context, resource, objects);
        this.context = context;
        resID = resource;
        data = objects;
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(resID, null);

        }
        TextView textView = (TextView) convertView.findViewById(R.id.xlist_item_tv);
        Log.e("myadapter", "getView: "+data.size() );
        Log.e("myadpter", "getView: "+data.get(0) );
        textView.setText(data.get(position));

        return convertView;
    }
}
